package rma.flp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.google.appengine.api.users.UserService;

@Controller
public class GalleryController {

	PictureRepository pictureRepository;
	UserService userService;

	@Autowired
	public GalleryController(PictureRepository pictureRepository, UserService userService) {
		this.pictureRepository = pictureRepository;
		this.userService = userService;
	}
	
	@RequestMapping("/gallery")
	public String show(ModelMap model) {
		String email = userService.getCurrentUser().getEmail();
		List<Picture> pictureList = pictureRepository.findByOwnerEmail(email);
		model.addAttribute(pictureList);
		return "gallery";
	}

}